//
// Created by hsj on 2021/12/30.
//
#include "iostream"
#include "t_arr.h"

//测试数组
void test_arr(){
    using namespace std;
    //建议初始化时候指定数组长度
    int arr001[10] = {1,2,3,4,5,6,7,8,9,10};
    //不建议这样做，除非你后续不想要长度否则编译器去计算？？
    int arr002[] = {1,2,3,4,5,6,7,8,9,10};
    int arr002_length = sizeof arr002 / sizeof (arr002[0]);

    cout<<arr002_length<<endl;

    //C++11
    int arr003[10] {1,2,3,4,5,6,7,8,9,10};
    int arr003_length = sizeof arr003 / sizeof (arr003[0]);
    for (int i = 0; i < arr003_length; i++){
        cout<<arr003[i];
        //制表符
        cout<<"\t";
    }

    //初始化默认值0
    int arr004[10]  = {};
    int arr005[10] {};
    int arr004_length = sizeof arr004 / sizeof (arr004[0]);
    int arr005_length = sizeof arr005 / sizeof (arr005[0]);
    for (int j = 0; j < arr004_length; j++){
        cout<<arr004[j];
        //制表符
        cout<<"\t";
    }
    for (int k = 0; k < arr005_length; k++){
        cout<<arr005[k];
        //制表符
        cout<<"\t";
    }

}